package com.deyuanyun.pic.ctrl.controller.vo.exinsp;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.ctrl.domain.EqptCptestStation;
import com.deyuanyun.pic.ctrl.domain.ExinspDcMiorRecord;
import com.deyuanyun.pic.ctrl.enumeration.*;
import com.deyuanyun.pic.ctrl.service.EQPTBaseService;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * 杂散电流：直流干扰监测记录
 */
public class ExinspDcMiorRecordVO extends ExinspBaseVO<ExinspDcMiorRecord> {

    // 管道名称
    private String pipeLineName;
    // 监测点编号(检测点名称)
    private String monitorPointName;
    // 干扰源自定义编号
    private String customNumber;
    // 监测点类型（测试桩编号、露管编号、缺陷点编号、其它）
    private String monitorPointType;
    // 绝对里程(m)
    private BigDecimal mileage;
    // 附近测试桩
    private String nagm;
    // 附近测试桩距离(m)
    private BigDecimal nagmMileage;
    // 位置描述
    private String locationDescription;
    // 干扰源类型（高压直流输电系统、直流牵引系统、其他阴极保护系统、其他直流用电设施）
    private String isType;
    // 干扰源名称
    private String isName;
    // 监测日期
    private String monitorDate;
    // 起始时间
    private String beginTime;
    // 结束时间
    private String endTime;
    // 读数时间间隔
    public Long readTimeInterval;
    // 管地电位最大偏移量（mV）
    public Long maxOffset;
    // 管地电位最小偏移量（mV）
    public Long minOffset;
    // 正向平均偏移量（mV）
    public Long positiveMeanOffset;
    // 负向平均偏移量（mV）
    public Long negativeMeanOffset;
    // 土壤电阻率（Ω•m）
    private BigDecimal soilResistivity;
    // 电位正于-850mV的时间/测试时间（%）
    private BigDecimal positivein850Ratio;
    // 电位正于-800mV的时间/测试时间（%）
    private BigDecimal positivein800Ratio;
    // 电位正于-750mV的时间/测试时间（%）
    private BigDecimal positivein750Ratio;
    // 电位正于0mV的时间/测试时间（%）
    private BigDecimal positivein0Ratio;
    // 直流干扰程度（强中弱）
    private String acInterferenceVoltage;
    // 修复建议（立即、计划、暂不、监控）
    private String repairSuggestion;
    // 最迟修复时间
    private String latestRepairTime;
    // 修复状态（已、未、修复中、难以）
    private String repairState;
    // 检测单位
    private String testingCompany;
    // 检测日期
    private String testingDate;
    // 监测点编号
    private String monitorPointId;
    // 外检任务编号
    private String exinspTaskId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getMonitorPointName() {
        return monitorPointName;
    }

    public void setMonitorPointName(String monitorPointName) {
        this.monitorPointName = monitorPointName;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public String getMonitorPointType() {
        return monitorPointType;
    }

    public void setMonitorPointType(String monitorPointType) {
        this.monitorPointType = monitorPointType;
    }

    public BigDecimal getMileage() {
        return mileage;
    }

    public void setMileage(BigDecimal mileage) {
        this.mileage = mileage;
    }

    public String getNagm() {
        return nagm;
    }

    public void setNagm(String nagm) {
        this.nagm = nagm;
    }

    public BigDecimal getNagmMileage() {
        return nagmMileage;
    }

    public void setNagmMileage(BigDecimal nagmMileage) {
        this.nagmMileage = nagmMileage;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public String getIsType() {
        return isType;
    }

    public void setIsType(String isType) {
        this.isType = isType;
    }

    public String getIsName() {
        return isName;
    }

    public void setIsName(String isName) {
        this.isName = isName;
    }

    public String getMonitorDate() {
        return monitorDate;
    }

    public void setMonitorDate(String monitorDate) {
        this.monitorDate = monitorDate;
    }

    public String getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(String beginTime) {
        this.beginTime = beginTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public Long getReadTimeInterval() {
        return readTimeInterval;
    }

    public void setReadTimeInterval(Long readTimeInterval) {
        this.readTimeInterval = readTimeInterval;
    }

    public Long getMaxOffset() {
        return maxOffset;
    }

    public void setMaxOffset(Long maxOffset) {
        this.maxOffset = maxOffset;
    }

    public Long getMinOffset() {
        return minOffset;
    }

    public void setMinOffset(Long minOffset) {
        this.minOffset = minOffset;
    }

    public Long getPositiveMeanOffset() {
        return positiveMeanOffset;
    }

    public void setPositiveMeanOffset(Long positiveMeanOffset) {
        this.positiveMeanOffset = positiveMeanOffset;
    }

    public Long getNegativeMeanOffset() {
        return negativeMeanOffset;
    }

    public void setNegativeMeanOffset(Long negativeMeanOffset) {
        this.negativeMeanOffset = negativeMeanOffset;
    }

    public BigDecimal getSoilResistivity() {
        return soilResistivity;
    }

    public void setSoilResistivity(BigDecimal soilResistivity) {
        this.soilResistivity = soilResistivity;
    }

    public BigDecimal getPositivein850Ratio() {
        return positivein850Ratio;
    }

    public void setPositivein850Ratio(BigDecimal positivein850Ratio) {
        this.positivein850Ratio = positivein850Ratio;
    }

    public BigDecimal getPositivein800Ratio() {
        return positivein800Ratio;
    }

    public void setPositivein800Ratio(BigDecimal positivein800Ratio) {
        this.positivein800Ratio = positivein800Ratio;
    }

    public BigDecimal getPositivein750Ratio() {
        return positivein750Ratio;
    }

    public void setPositivein750Ratio(BigDecimal positivein750Ratio) {
        this.positivein750Ratio = positivein750Ratio;
    }

    public BigDecimal getPositivein0Ratio() {
        return positivein0Ratio;
    }

    public void setPositivein0Ratio(BigDecimal positivein0Ratio) {
        this.positivein0Ratio = positivein0Ratio;
    }

    public String getAcInterferenceVoltage() {
        return acInterferenceVoltage;
    }

    public void setAcInterferenceVoltage(String acInterferenceVoltage) {
        this.acInterferenceVoltage = acInterferenceVoltage;
    }

    public String getRepairSuggestion() {
        return repairSuggestion;
    }

    public void setRepairSuggestion(String repairSuggestion) {
        this.repairSuggestion = repairSuggestion;
    }

    public String getLatestRepairTime() {
        return latestRepairTime;
    }

    public void setLatestRepairTime(String latestRepairTime) {
        this.latestRepairTime = latestRepairTime;
    }

    public String getRepairState() {
        return repairState;
    }

    public void setRepairState(String repairState) {
        this.repairState = repairState;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public String getTestingDate() {
        return testingDate;
    }

    public void setTestingDate(String testingDate) {
        this.testingDate = testingDate;
    }

    public String getMonitorPointId() {
        return monitorPointId;
    }

    public void setMonitorPointId(String monitorPointId) {
        this.monitorPointId = monitorPointId;
    }

    public String getExinspTaskId() {
        return exinspTaskId;
    }

    public void setExinspTaskId(String exinspTaskId) {
        this.exinspTaskId = exinspTaskId;
    }

    EQPTBaseService eqptBaseService = SpringAppliction.getBean(EQPTBaseService.class);

    public void fromDomain(ExinspDcMiorRecord domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 监测点编号(检测点名称)
        this.monitorPointName = domain.getMonitorPointName();
        // 干扰源自定义编号
        this.customNumber = domain.getCustomNumber();
        // 监测点类型（测试桩编号、露管编号、缺陷点编号、其它）
        this.monitorPointType = MonitorPointTypeEnum.getLabel(domain.getMonitorPointType());
        // 绝对里程(m)
        this.mileage = NumberUtil.toMeter(domain.getMileage());
        // 附近测试桩
        EqptCptestStation eqptCptestStation = eqptBaseService.queryObjectByPrimaryKey(EqptCptestStation.class, domain.getNagm());
        this.nagm = eqptCptestStation==null ? null : eqptCptestStation.getCustomNumber();
        // 附近测试桩距离(m)
        this.nagmMileage = NumberUtil.toMeter(domain.getNagmMileage());
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 干扰源类型（高压直流输电系统、直流牵引系统、其他阴极保护系统、其他直流用电设施）
        this.isType = InterferenceSourceTypeEnum.getLabelBycode(domain.getIsType());
        // 干扰源名称
        this.isName = domain.getIsName();
        // 监测日期
        this.monitorDate = DateFormat.format(domain.getMonitorDate());
        // 起始时间
        this.beginTime = domain.getBeginTime();
        // 结束时间
        this.endTime = domain.getEndTime();
        // 读数时间间隔
        this.readTimeInterval = domain.getReadTimeInterval();
        // 管地电位最大偏移量（mV）
        this.maxOffset = domain.getMaxOffset();
        // 管地电位最小偏移量（mV）
        this.minOffset = domain.getMinOffset();
        // 正向平均偏移量（mV）
        this.positiveMeanOffset = domain.getPositiveMeanOffset();
        // 负向平均偏移量（mV）
        this.negativeMeanOffset = domain.getNegativeMeanOffset();
        // 土壤电阻率（Ω•m）
        this.soilResistivity = domain.getSoilResistivity();
        // 电位正于-850mV的时间/测试时间（%）
        this.positivein850Ratio = domain.getPositivein850Ratio();
        // 电位正于-800mV的时间/测试时间（%）
        this.positivein800Ratio = domain.getPositivein800Ratio();
        // 电位正于-750mV的时间/测试时间（%）
        this.positivein750Ratio = domain.getPositivein750Ratio();
        // 电位正于0mV的时间/测试时间（%）
        this.positivein0Ratio = domain.getPositivein0Ratio();
        // 直流干扰程度（强中弱）
        this.acInterferenceVoltage = CurrentFerenceEnum.getLabelBycode(domain.getAcInterferenceVoltage());
        // 修复建议（立即、计划、暂不、监控）
        this.repairSuggestion =  CodeUtil.getName(domain.getRepairSuggestion());
        // 最迟修复时间
        this.latestRepairTime = DateFormat.format(domain.getLatestRepairTime());
        // 修复状态（已、未、修复中、难以）
        this.repairState = RepairStateEnum.getLabel(domain.getRepairState());
        // 检测单位
        this.testingCompany = domain.getTestingCompany();
        // 检测日期
        this.testingDate = DateFormat.format(domain.getTestingDate());
        // 监测点编号
        this.monitorPointId = domain.getMonitorPointId();
        // 外检任务编号
        this.exinspTaskId = domain.getExinspTaskId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());

    }

    public Page<ExinspDcMiorRecordVO> fromDomainList(Page<ExinspDcMiorRecord> domainList) {

        Page<ExinspDcMiorRecordVO> list = new Page<ExinspDcMiorRecordVO>();
        for (ExinspDcMiorRecord exinspDcMiorRecord : domainList) {
            ExinspDcMiorRecordVO exinspDcMiorRecordVO = new ExinspDcMiorRecordVO();
            exinspDcMiorRecordVO.fromDomain(exinspDcMiorRecord);
            list.add(exinspDcMiorRecordVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}